import sys
from pylab import *

#serpent_id #sigla_estado

N = [1,3,4,10,22,23,27,14]
NE = [2,5,6,15,17,18,20,26]
SE = [8,13,25,19]
S = [16,24,21]
C = [7,9,12,11]

f = open(sys.argv[1],"r")

norte = nordeste = sudeste = sul = centro = 0

for line in f:
	sigla = int(line.split()[1])
	if sigla in N:
		norte += 1
	elif sigla in NE:
		nordeste += 1
	elif sigla in SE:
		sudeste += 1
	elif sigla in S:
		sul += 1
	elif sigla in C:
		centro += 1
	

total = norte + nordeste + sudeste + sul + centro

norte = int((float(norte)/float(total))*100)
nordeste = int((float(nordeste)/float(total))*100)
sudeste = int((float(sudeste)/float(total))*100)
sul = int((float(sul)/float(total))*100)
centro = int((float(centro)/float(total))*100)
"""
Make a pie chart - see
http://matplotlib.sf.net/matplotlib.pylab.html#-pie for the docstring.

This example shows a basic pie chart with labels optional features,
like autolabeling the percentage, offsetting a slice with "explode"
and adding a shadow.

Requires matplotlib0-0.70 or later

"""


# make a square figure and axes
figure(1, figsize=(6,6))
ax = axes([0.1, 0.1, 0.8, 0.8])

labels = 'Norte', 'Nordeste', 'Sudeste', 'Sul', 'Centro-Oeste'
fracs = [norte,nordeste,sudeste, sul,centro]

explode=(0, 0, 0, 0,0)
pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
title('Cobras por Regiao do Pais', bbox={'facecolor':'0.8', 'pad':5})

show()


